import type { TsrpcConfig } from 'tsrpc-cli';

export default <TsrpcConfig>{
    // Generate ServiceProto
    proto: [
        // {
        //     ptlDir: 'src/shared/protocols', // Protocol dir
        //     output: 'src/shared/protocols/serviceProto.ts',
        //     apiDir: 'src/api',   // API dir
        //     docDir: 'docs',     // API documents dir
        //     ptlTemplate: { baseFile: 'src/shared/protocols/base.ts' },
        //     msgTemplate: { baseFile: 'src/shared/protocols/base.ts' },
        // },
        {
            ptlDir: 'src/shared/api_bot', // Protocol dir
            output: 'src/shared/api_bot/serviceProto.ts',
            apiDir: 'src/api_bot',   // API dir
            docDir: 'docs/api_bot',     // API documents dir
            ptlTemplate: { baseFile: 'src/shared/api_bot/base.ts' },
            msgTemplate: { baseFile: 'src/shared/api_bot/base.ts' },
        },
        {
            ptlDir: 'src/shared/api_client',
            output: 'src/shared/api_client/serviceProto.ts',
            apiDir: 'src/api_client',
            docDir: 'docs/api_client',
            ptlTemplate: { baseFile: 'src/shared/api_client/base.ts' },
            msgTemplate: { baseFile: 'src/shared/api_client/base.ts' },
        },{
            ptlDir: 'src/shared/api_backend',
            output: 'src/shared/api_backend/serviceProto.ts',
            apiDir: 'src/api_backend',
            docDir: 'docs/api_backend',
            ptlTemplate: { baseFile: 'src/shared/api_backend/base.ts' },
            msgTemplate: { baseFile: 'src/shared/api_backend/base.ts' },
        }
    ],
    // Sync shared code
    sync: [
        {
            from: 'src/shared/api_bot',
            to: '../koishi-app/external/dew-bot/src/shared',
            type: 'copy'
        },
        {
            from: 'src/shared/api_client',
            to: '../web_client/src/shared/poto',
            type: 'copy'
        },
        {
            from: 'src/shared/face',
            to: '../web_client/src/shared/face',
            type: 'copy'
        },
        {
            from: 'src/shared/face',
            to: '../koishi-app/external/dew-bot/src/shared/face',
            type: 'copy'
        }
    ],
    // Dev server
    dev: {
        autoProto: true,        // Auto regenerate proto
        autoSync: true,         // Auto sync when file changed
        autoApi: true,          // Auto create API when ServiceProto updated
        watch: ['src', '!src/**/*.json'],           // Restart dev server when these files changed
        entry: 'src/index.ts',  // Dev server command: node -r ts-node/register {entry}
    },
    // Build config
    build: {
        autoProto: true,        // Auto generate proto before build
        autoSync: true,         // Auto sync before build
        autoApi: true,          // Auto generate API before build
        outDir: 'dist',         // Clean this dir before build
    }
}